import 'package:flutter/material.dart';

class MyAppBar extends StatelessWidget {
  MyAppBar({Key? key, required this.title});

  final Widget title;

  @override
  Widget build(BuildContext context) {
    return new Container(
      height: 100.0,
      padding: const EdgeInsets.symmetric(horizontal: 8.0),
      decoration: new BoxDecoration(color: Colors.blue[500]),
      // row 是水平方向的线性布局
      child: new Row(
        mainAxisAlignment: MainAxisAlignment.spaceEvenly,
        children: <Widget>[
          new IconButton(
            onPressed: null,
            icon: new Icon(Icons.menu),
            tooltip: 'Navigation menu',
            iconSize: 60.0,
          ),
          new Expanded(child: title),
          new IconButton(
            onPressed: null,
            icon: new Icon(Icons.search),
            tooltip: 'Search',
            iconSize: 60.0,
          ),
        ],
      ),
    );
  }
}

class MyScaffold extends StatelessWidget {
  @override
  Widget build(BuildContext context) {

    return new Material(
      child: new Column(
        children: <Widget>[
          new MyAppBar(
            title: new Text(
              '测试小组件',
              style: Theme.of(context).primaryTextTheme.titleMedium,
            ),
          ),
          new Expanded(
                child: new Center(
                  child: new Text("Hello, world!"),

                ))
        ],
      ),
    );
  }

}

void main(){
  runApp(new MaterialApp(
    title: 'My App',
    home: new MyScaffold(),
  ));
}
